//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS SagemakerEdge service.
///
/// SageMaker Edge Manager dataplane service for communicating with active agents.
public struct SagemakerEdge: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the SagemakerEdge client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "SagemakerEdge",
            serviceIdentifier: "edge.sagemaker",
            signingName: "sagemaker",
            serviceProtocol: .restjson,
            apiVersion: "2020-09-23",
            endpoint: endpoint,
            errorType: SagemakerEdgeErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Use to get the active deployments from a device.
    @Sendable
    @inlinable
    public func getDeployments(_ input: GetDeploymentsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetDeploymentsResult {
        try await self.client.execute(
            operation: "GetDeployments", 
            path: "/GetDeployments", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Use to get the active deployments from a device.
    ///
    /// Parameters:
    ///   - deviceFleetName: The name of the fleet that the device belongs to.
    ///   - deviceName: The unique name of the device you want to get the configuration of active deployments from.
    ///   - logger: Logger use during operation
    @inlinable
    public func getDeployments(
        deviceFleetName: String? = nil,
        deviceName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetDeploymentsResult {
        let input = GetDeploymentsRequest(
            deviceFleetName: deviceFleetName, 
            deviceName: deviceName
        )
        return try await self.getDeployments(input, logger: logger)
    }

    /// Use to check if a device is registered with SageMaker Edge Manager.
    @Sendable
    @inlinable
    public func getDeviceRegistration(_ input: GetDeviceRegistrationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetDeviceRegistrationResult {
        try await self.client.execute(
            operation: "GetDeviceRegistration", 
            path: "/GetDeviceRegistration", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Use to check if a device is registered with SageMaker Edge Manager.
    ///
    /// Parameters:
    ///   - deviceFleetName: The name of the fleet that the device belongs to.
    ///   - deviceName: The unique name of the device you want to get the registration status from.
    ///   - logger: Logger use during operation
    @inlinable
    public func getDeviceRegistration(
        deviceFleetName: String? = nil,
        deviceName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetDeviceRegistrationResult {
        let input = GetDeviceRegistrationRequest(
            deviceFleetName: deviceFleetName, 
            deviceName: deviceName
        )
        return try await self.getDeviceRegistration(input, logger: logger)
    }

    /// Use to get the current status of devices registered on SageMaker Edge Manager.
    @Sendable
    @inlinable
    public func sendHeartbeat(_ input: SendHeartbeatRequest, logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "SendHeartbeat", 
            path: "/SendHeartbeat", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Use to get the current status of devices registered on SageMaker Edge Manager.
    ///
    /// Parameters:
    ///   - agentMetrics: For internal use. Returns a list of SageMaker Edge Manager agent operating metrics.
    ///   - agentVersion: Returns the version of the agent.
    ///   - deploymentResult: Returns the result of a deployment on the device.
    ///   - deviceFleetName: The name of the fleet that the device belongs to.
    ///   - deviceName: The unique name of the device.
    ///   - models: Returns a list of models deployed on the the device.
    ///   - logger: Logger use during operation
    @inlinable
    public func sendHeartbeat(
        agentMetrics: [EdgeMetric]? = nil,
        agentVersion: String? = nil,
        deploymentResult: DeploymentResult? = nil,
        deviceFleetName: String? = nil,
        deviceName: String? = nil,
        models: [Model]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws {
        let input = SendHeartbeatRequest(
            agentMetrics: agentMetrics, 
            agentVersion: agentVersion, 
            deploymentResult: deploymentResult, 
            deviceFleetName: deviceFleetName, 
            deviceName: deviceName, 
            models: models
        )
        return try await self.sendHeartbeat(input, logger: logger)
    }
}

extension SagemakerEdge {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: SagemakerEdge, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
